package zhtt.springdata.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import zhtt.springdata.entity.User;

import java.util.List;

/**
 * Created by ztt on 2018/3/17.
 * Spring Data允许在方法名中使用四种动词： get、 read、 find和count
 */
public interface UserRepository extends JpaRepository<User, Long> {

    List<User> findByUsername(String username);

    List<User> readByUsername(String username);

    List<User> readByUsernameOrEmail(String username, String email);

    List<User> findByUsernameIn(List<String> usernameList);

    @Query("select u from User u where u.username like '%' || :username || '%'")
    List<User> findByUsernameLike(@Param("username") String username);

    //List<Order> findByShippingDateBetween(Date start, Date end)
}
